﻿@namespace SwashbucklerDiary.Components
@inherits DialogComponentBase

<MultiDisplay OnUpdate="UpdateDisplay">
    <MobileContent>
        <MBottomSheet Value="Value"
                      ValueChanged="ValueChanged"
                      ContentClass="rounded-t-lg">
            <ActivatorContent>
                <MButton @attributes="@context.Attrs"
                         Icon="true">
                    @ButtonContent
                </MButton>
            </ActivatorContent>
            <ChildContent>
                <MCard Class="rounded-t-lg py-2">
                    <MList>
                        @foreach (var item in DynamicListItems)
                        {
                            @if (item.Show)
                            {
                                <MListItem OnClick="()=>OnClick(item.OnClick)">
                                    <MListItemIcon>
                                        <MIcon>
                                            @(item.Icon)
                                        </MIcon>
                                    </MListItemIcon>
                                    <MListItemContent>
                                        @(I18n.T(item.Text))
                                    </MListItemContent>
                                </MListItem>
                                if (DynamicListItems.Last(it => it.Show) != item)
                                {
                                    <MDivider></MDivider>
                                }
                            }
                        }
                        <MListItem>
                            <MButton Rounded="true"
                                     Block="true"
                                     Depressed="true"
                                     Large="true"
                                     Class="text-subtitle-1"
                                     OnClick="HandleOnCancel">
                                @(I18n.T("Share.Cancel"))
                            </MButton>
                        </MListItem>
                    </MList>
                </MCard>
            </ChildContent>
        </MBottomSheet>
    </MobileContent>
    <DesktopContent>
        <MMenu Value="Value"
               ValueChanged="ValueChanged"
               Rounded="@("lg")"
               Bottom="true"
               Right="true"
               Transition="scroll-x-reverse-transition">
            <ActivatorContent>
                <MButton @attributes="@context.Attrs"
                         Icon="true">
                    @ButtonContent
                </MButton>
            </ActivatorContent>
            <ChildContent>
                <MList MinWidth="150">
                    @foreach (var item in DynamicListItems)
                    {
                        @if (item.Show)
                        {
                            <MListItem Dense="true"
                                       OnClick="()=>OnClick(item.OnClick)">
                                <MListItemContent>
                                    @(I18n.T(item.Text))
                                </MListItemContent>
                            </MListItem>
                        }
                    }
                </MList>
            </ChildContent>
        </MMenu>
    </DesktopContent>
</MultiDisplay>